using System;
using UnityEngine;

[Serializable]
public class MissionTargetKillMob : MissionTargetBase
{
	[SerializeField]
	private bool Aggressive = true;

	[SerializeField]
	private bool Passive = true;

	[SerializeField]
	private bool Civilian = true;

	[SerializeField]
	private bool Police = true;

	private void OnDisable()
	{
		if (curParametr.isStarted)
		{
			OnStopTarget();
		}
	}

	protected override void OnShowStartMsg()
	{
		MessageManager.instance.CreateMessage(base.messageStart, IdClForMsg.levelUp, TypeAnimMessage.longTimeMessage, 5f);
	}

	protected override bool OnStartTarget()
	{
		if (!base.OnStartTarget())
		{
			return false;
		}
		ManagerMissions.killMob += OnKillMOB;
		return true;
	}

	public override void OnStopTarget()
	{
		base.OnStopTarget();
		ManagerMissions.killMob -= OnKillMOB;
	}

	private void OnKillMOB(EnemyBehavior curEnemy)
	{
		if (curParametr.isComplete)
		{
			return;
		}
		switch (curEnemy.behaviorModel)
		{
		case BehaviorModel.Aggressive:
			if (!Aggressive)
			{
				return;
			}
			break;
		case BehaviorModel.Passive:
			if (!Passive)
			{
				return;
			}
			break;
		case BehaviorModel.Civilian:
			if (!Civilian)
			{
				return;
			}
			break;
		case BehaviorModel.Police:
			if (!Police)
			{
				return;
			}
			break;
		}
		curCountTarget++;
		curParametr.UpdateValue();
		if (TargetIsComplete())
		{
			CompleteTarget();
		}
	}
}
